package com.zhuanzhuan.hero.user.util;

import org.apache.commons.lang3.StringUtils;

/**
 * @ClassName DesensitizeUtil
 * @Description
 * @Author hanjunjun
 * @Date 2024/7/20 11:08
 */
public class DesensitizeUtil {

    /**
     * 手机号脱敏
     *
     * @param mobile
     * @return java.lang.String
     * @author  hanjunjun
     * @date 2024/7/20
     **/
    public static String desensitizeMobile(String mobile) {
        if (StringUtils.isBlank(mobile)) {
            return StringUtils.EMPTY;
        }

        return mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
    }

    public static void main(String []args){
        System.out.println(DesensitizeUtil.desensitizeMobile("15234290842"));
    }
}
